<!-- 业务派单功能 -->
<template>
  <el-container class="electronicSignature">

    <el-header height="36px">
      <header-title style="text-align: center;padding-left: 0px;" :title="$route.meta.title" />
    </el-header>
    <el-main class="mainDetails">
      <div>
        <!-- 任务单 -->
        <SearchPanel title="任务单">
          <div ref="queryFormBox" class="search-flex-box">
            <PmsForm
              ref="formRef"
              v-model="queryParams"
              :form-option="formOption"
              :select-list="dicLists"
              :line-height="38"
            >
              <template #taskDescription>
                <el-input
                  v-model="queryParams.taskDescription"
                  style="width: 100%"
                  maxlength="500"
                  :rows="4"
                  type="textarea"
                  resize="none"
                  :disabled="disabledType"
                  placeholder="请输入内容"
                />
              </template>
            </PmsForm>
          </div>
        </SearchPanel>
        <SearchList title="派单项目列表" style="margin-top: 16px">
          <template #header-btn>
            <BtnConfig ref="btnConfigRef" :btn-configs="btnOption" @propClick="btnClick" />
          </template>
          <template #body>
            <MyTable
              id="id"
              ref="tableRef"
              :table-data="tableData"
              :columns="colOption"
              :col-option-enum="dicLists"
              :is-selection="true"
            >
              <template #prjName="{ scope }">
                <el-button type="text" @click="prjNameFun(scope)">{{ scope.prjName }}</el-button>
              </template>
              <template #handlingTime="{ scope }">
                <div v-if="scope.handlingTime > 9" class="Colorred">{{ scope.handlingTime }}天 </div>
                <div v-else-if="scope.handlingTime">{{ scope.handlingTime }}天</div>
                <div v-else>{{ scope.handlingTime }}</div>
              </template>
              <template #processingProgress="{ scope }">
                <el-button v-if="scope.processingProgress == '1'" type="text" @click="lookOpinion(scope)">处理中</el-button>
                <el-button v-if="scope.processingProgress == '2'" type="text" @click="lookOpinion(scope)">已完成</el-button>
                <el-button v-if="scope.processingProgress == '3'" type="text" @click="lookOpinion(scope)">已回退待重派</el-button>
                <div v-if="scope.processingProgress == '4'">请点击重派</div>
                <!-- { '1': '处理中', '2': '已完成', '3': '已回退待重派', '4': '请点击重派' } -->
              </template>
              <template #transferOrNot="{ scope }">
                <el-button v-if="scope.transferOrNot == 1" type="text" @click="transferOrNotFun(scope)">是</el-button>
              </template>
              <template #sendStaffName="{ scope }">
                <el-button v-if="!scope.sendStaffName" type="text" @click="sendStaffFun(scope)">选择</el-button>
                <el-button v-else-if="scope.processingProgress == 3 || scope.processingProgress == 4" type="text" @click="sendStaffFun(scope)">重新派单</el-button>
                <div v-else>{{ scope.sendStaffName }}</div>
              </template>
              <template #prjFile="{ scope }">
                <el-button type="text" @click="downLoadFile(scope)">{{ shwoFileName(scope) }}</el-button>
              </template>
            </MyTable>
            <div class="topBtn">
              <div ref="topBtnText" style="color:red;margin:20px 0px;">*点击【确定】后会把所有数据发起流程,并关闭当前派单页面，同时生成对应的”已办信息“进行后续进度追踪，请前往工作台/我的已办,通过”待办类型“查询业务派单进行操作'</div>
              <BtnConfig ref="btnConfigRef" class="topBtnBox" :btn-configs="btnOptionBotm" @propClick="btnClick" />
            </div>
            <pagination
              v-if="pageParam.total > 10"
              :total="pageParam.total"
              :page.sync="pageParam.pageNum"
              :limit.sync="pageParam.pageSize"
              @pagination="doSearch"
            />
          </template>
        </SearchList>
      </div>
    </el-main>
    <!-- 基本信息弹框 -->
    <el-dialog
      v-dialogDrag
      :close-on-click-modal="false"
      title=""
      :visible.sync="dialogVisible"
      width="50%"
      height="100%"
      modal
      class="message-dialog"
      :before-close="handleColse"
      style="text-align: justify;"
    >
      <template #title>
        <div class="search-panel-header">
          <div class="search-panel-icon" />
          <div class="search-panel-title">项目基本信息</div>
        </div>
      </template>
      <PmsForm
        v-model="queryParamsBasic"
        :form-option="formOptionBasic"
        :select-list="dicLists"
        style="width: 90%;"
      >
        <template #remarks>
          <el-input
            v-model="queryParamsBasic.remarks"
            style="width: 100%"
            :rows="4"
            type="textarea"
            resize="none"
            :disabled="true"
          />
        </template>
      </PmsForm>
    </el-dialog>
    <!-- 派单项目添加弹框 -->
    <BusinessOrderPush ref="BusinessOrderPush" :table-data-old="tableDataOld" @update-value="updateValue" />
    <!-- 接单人员选择 -->
    <el-dialog
      ref="DialogRef"
      v-dialogDrag
      :close-on-click-modal="false"
      title="接单人员选择"
      :visible.sync="sendOrdersDialog"
      width="50%"
      height="100%"
      modal
      class="pms-dialog"
      :before-close="handleColse"
      style="text-align:center"
    >
      <div ref="queryFormBoxTwo" class="search-flex-box">
        <el-form
          ref="validataForm"
          :model="formVal"
          label-width="260px"
          class="el-form pms-form"
          size="mini"
          :inline="true"
          style="line-height: 28px;"
        >
          <el-row :gutter="24">
            <el-col :span="9">
              <el-form-item label="姓名" style="width:100%;" prop="zanguMoney">
                <el-input v-model.trim="formVal.name" style="width:160px" />
              </el-form-item>
            </el-col>
            <el-col :span="9">
              <el-form-item label="账号" style="width:100%;" prop="zanguMoney">
                <el-input v-model.trim="formVal.loginName" style="width:160px" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div class="searchBtn">
          <el-button type="primary" class="pms-button-primary" @click="transferRecordAdd">查询</el-button>
        </div>
      </div>
      <div class="container">
        <div class="select">
          <div class="box">
            <div class="title">可选办理人(内部人员)</div>
            <div class="content">
              <el-tree
                ref="userTree"
                class="userTree-container"
                empty-text=""
                :data="toSelectdata"
                default-expand-all
                icon-class=""
                @current-change="currentChange"
                @node-click="userClick"
              >
                <template slot-scope="{ node, data }">
                  <span class="custom-tree-node">
                    <span v-if="!data.isLeaf" style="margin-right: 6px;font-size: 14px;color: #606266;" :class="[node.expanded ? 'el-icon-folder-opened' : 'el-icon-folder']" />
                    <span v-else style="margin-right: 6px;font-size: 14px;color: #606266;" class="el-icon-user" />
                    <span style="font-size: 14px;color: #606266;">{{ data.text }}&nbsp;&nbsp;{{ data.loginName?`(${data.loginName})`: '' }}</span>
                  </span>
                </template>
              </el-tree>
            </div>
          </div>
          <div class="box">
            <div class="title">可选办理人(服务商)</div>
            <div class="content">
              <el-tree
                ref="userTree"
                class="userTree-container"
                empty-text=""
                :data="toSelectdataTwo"
                default-expand-all
                icon-class=""
                @current-change="currentChange"
                @node-click="userClick"
              >
                <template slot-scope="{ node, data }">
                  <span class="custom-tree-node">
                    <span v-if="!data.isLeaf" style="margin-right: 6px;font-size: 14px;color: #606266;" :class="[node.expanded ? 'el-icon-folder-opened' : 'el-icon-folder']" />
                    <span v-else style="margin-right: 6px;font-size: 14px;color: #606266;" class="el-icon-user" />
                    <span style="font-size: 14px;color: #606266;">{{ data.text }}&nbsp;&nbsp;{{ data.loginName?`(${data.loginName})`: '' }}</span>
                  </span>
                </template>
              </el-tree>
            </div>
          </div>
        </div>
      </div>
      <div class="containerTwo">
        <div class="select">
          <div class="box">
            <div class="title">已选办理人</div>
            <div class="contentTwo">
              <div v-if="userSelectedName" class="user-select-item">
                <span class="el-icon-user" style="margin-right: 6px;" />
                <span>{{ userSelectedName }}&nbsp;&nbsp;{{ selectedUserId ? `(${selectedUserId})` : '' }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="pms-button-primary" size="small" @click="pushAdd">确 定</el-button>
        <el-button class="pms-button" size="small" @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 说明弹框 -->
    <el-dialog
      ref="DialogRef"
      v-dialogDrag
      :close-on-click-modal="false"
      :title="dialogsTitle"
      :visible.sync="dialogs"
      width="50%"
      height="100%"
      modal
      class="pms-dialog"
      :before-close="handleColse"
      style="text-align:center"
    >
      <MyTable
        id="idTwo"
        ref="myTableRef"
        :table-data="explainTableData"
        :columns="colOptionTwo"
        :col-option-enum="dicLists"
        :is-selection="false"
      />
    </el-dialog>
    <!-- 查看回执 -->
    <el-dialog
      ref="DialogRef"
      v-dialogDrag
      :close-on-click-modal="false"
      title="回执内容"
      :visible.sync="opinionDialogs"
      width="50%"
      height="100%"
      modal
      class="pms-dialog"
      :before-close="handleColse"
      style="text-align:center"
    >
      <el-input
        v-model="opinionVal"
        style="width: 100%;margin-top: 10px;"
        maxlength="500"
        :rows="4"
        type="textarea"
        resize="none"
        :disabled="true"
      />
    </el-dialog>
  </el-container>
</template>

<script>
  import HeaderTitle from '@/components/basic/HeaderTitle'
  import SearchPanel from '@/components/basic/SearchPanel.vue'
  import PmsForm from '@/views/businessOperation/pmsForm'
  import SearchList from '@/components/basic/SearchList'
  import MyTable from '@/components/basic/myTable'
  import SysConst from '@/common/const'
  import BtnConfig from '@/components/basic/btnConfig.vue'
  import { getDropdownData } from '@/api/common' // 字典接口
  import { newOpenPostWindow } from '@/utils/newRequestCommonFormjs'
  import { clonePage } from '@/utils'
  import { getQueryObject } from '@/utils' // 获取url地址信息
  import { getProjectInfo, getUserInfo, insertTDispatchInfo, getProjectInfoByPrjId, getTDispatchInfoById, getTDispatchProjectById, getTransferRecord, getSendStaffTree, getServicerSendStaffTree, creatDispatchProjectFlow, applyTokenByCode, getForeignConfig, transferTokenPost } from '@/api/businessOperation/index' // 列表接口
  import BusinessOrderPush from '@/views/businessOperation/pushbusinessOrder.vue'

  // 定义配置
  // 查询条件配置
  const formOption = {
      size: 'mini',
      inline: true,
      labelWidth: '160px',
      itemData: [
          {
              type: 'select',
              prop: 'dispatchType',
              value: '',
              width: '',
              colSpan: 6,
              label: '派单类型',
              dicType: 'TDISPATCH_TYPE',
              clearable: true,
              dicProp: {
                  label: 'dictName',
                  value: 'dictId'
              },
              rule: [
                  { required: true, message: '请选择业务专业', trigger: 'change' }
              ]
          },
          {
              type: 'datePicker',
              prop: 'deadline',
              value: '',
              width: '',
              colSpan: 6,
              clearable: true,
              label: '解决期限',
              placeholder: '请选择',
            valueFormat: 'yyyy-MM-dd',
              rule: [
                  { required: true, message: '请选择解决期限', trigger: 'blur' }
                  // { pattern: /^\d+(\.\d{1,1})?$/, trigger: 'blur', message: '请输入数字值' }
              ]
          },
          {
              type: 'input',
              prop: 'taskTitle',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              label: '任务标题',
              placeholder: '请输入',
              rule: [
                  { required: true, message: '请输入任务标题', trigger: 'blur' }
              ]
          },
          {
              type: 'slot',
              prop: 'taskDescription',
              value: '',
              width: '',
              colSpan: 24,
              clearable: true,
              label: '任务描述',
              rule: [
                  { required: true, message: '请输入任务描述', trigger: 'blur' }
              ]
          }
      ]
  }

  // 基本信息查询条件配置
  const formOptionBasic = {
      size: 'mini',
      inline: true,
      labelWidth: '160px',
      itemData: [
          {
              type: 'input',
              prop: 'prjCode',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              disabled: true,
              label: '编码'
          },
          {
              type: 'input',
              prop: 'setId',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              disabled: true,
              label: '站址编码'
          },
          {
              type: 'input',
              prop: 'prjName',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              disabled: true,
              label: '名称'
          },
          {
              type: 'input',
              prop: 'setName',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              disabled: true,
              label: '站址名称'
          },
          {
              type: 'input',
              prop: 'prjYear',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              disabled: true,
              label: '项目年份'
          },
          {
              type: 'input',
              prop: 'orgName',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              disabled: true,
              label: '建设单位'
          },
          {
              type: 'input',
              prop: 'prjTypeName',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              disabled: true,
              label: '项目类型'
          },
          {
              type: 'input',
              prop: 'buildModesName',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              disabled: true,
              label: '建设方式'
          },
          {
              type: 'input',
              prop: 'isReceiveName',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              disabled: true,
              label: '立项申请人'
          },
          {
              type: 'input',
              prop: 'projectManagerName',
              value: '',
              width: '',
              colSpan: 12,
              clearable: true,
              disabled: true,
              label: '项目管理岗位'
          },
          {
              type: 'slot',
              prop: 'remarks',
              value: '',
              width: '',
              colSpan: 24,
              clearable: true,
              placeholder: '',
              label: '备注'
          }
      ]
  }

  // 列表表头配置
  const colOption = [
      { label: '编码', width: '160', prop: 'prjCode' },
      { label: '名称', width: '220', prop: 'prjName', isShowTooltip: true },
      { label: '站址编号', width: '160', prop: 'siteId' },
      { label: '站址名称', width: '220', prop: 'siteName' },
      { label: '项目阶段', width: '120', prop: 'prjStageName' },
      { label: '派单编码', width: '160', prop: 'sendCode' },
      { label: '处理时长', width: '120', prop: 'handlingTime' },
      { label: '处理进度', width: '120', prop: 'processingProgress', isShowTooltip: true },
      { label: '是否转派', width: '80', prop: 'transferOrNot', filter: { '0': '否', '1': '是' }},
      { label: '接单人', width: '100', prop: 'sendStaffName' },
      { label: '附件', width: '100', prop: 'prjFile' }
  ]
  const colOptionTwo = [
      { label: '转派人', width: '', prop: 'transferStaff' },
      { label: '转派至', width: '', prop: 'transferredPerson', isShowTooltip: true },
      { label: '时间', width: '', prop: 'opinionDate' },
      { label: '说明', width: '300', prop: 'opinion' }
  ]

  // 列表按钮配置
  const btnOption = [
      { label: '添加', fun: 'pushFun', type: '' },
      { label: '删除', fun: 'delFun', type: '' }
  ]

  // 确认关闭按钮配置
  const btnOptionBotm = [
      { label: '确认', fun: 'formAdd', type: '' },
      { label: '关闭', fun: 'dialogCheckboxFun', type: '' }
  ]

  export default {
      name: 'BusinessSendorders',
      components: {
          HeaderTitle,
          SearchPanel,
          SearchList,
          MyTable,
          PmsForm,
          BtnConfig,
          BusinessOrderPush
      },
      data() {
          return {
              queryParams: {}, // 查询数据
              queryParamsBasic: {}, // 基本信息查询数据
              formOption, // 查询条件配置项
              formOptionBasic, // 基本信息查询
              formVal: {}, // 派单人选择
              tableData: [], // 列表数据
              tableDataOld: [], // 传个新增数据页面的列表
              tableDataNew: [], // 添加之后每次获取新的数据
              explainTableData: [], // 说明列表数据
              colOption, // 列表表头
              colOptionTwo, // 说明列表表头
              btnOption, // 列表按钮
              btnOptionBotm, // 确认取消按钮
              fixedCheckOption: colOption, // 固定字段
              sendStaValObj: {}, // 存放重新派单信息
              dicLists: {}, // 下拉框字典选项集合
              // 分页信息
              pageParam: {
                  pageSize: SysConst.PAGESIZE, // 每页显示val条
                  pageNum: SysConst.CURRENT_PAGE, // 当前页
                  total: SysConst.TOTAL // 总数
              },
              prjParams: {}, // 页面路由参数集
              disabledType: false, // 默认可输入内容
              dialogVisible: false,
              sendOrdersDialog: false,
              opinionDialogs: false, // 查看回执
              opinionVal: '', // 回执内容
              userSelected: {}, // 已选择的人员节点
              toSelectdata: [], // 可选办理人树型(内部人员)
              toSelectdataTwo: [], // 可选办理人树型(服务商)
              selectedUserId: '', // 已选办理人账号
              dialogsTitle: '', // 公共弹框
              dialogs: false,
              searchFlexBox: true // 不展示边框
          }
      },

      computed: {
        userSelectedName() {
          return this.userSelected.empName
        }
      },
      async created() {
          // 获取url
          const { prjId, workItemId, acctId, pwdaToken, sendType } = getQueryObject()
          if (sendType === '2') {
            var param = { acctId: acctId, token: pwdaToken }
            await transferTokenPost(param).then(res => {
                window.sessionStorage.setItem('china-tower-token-pms20', res.data)
            })
          }
          this.prjParams = {
            prjId,
            workItemId
          }
          // form 高度
          this.$nextTick(() => {
              this.setHeight(false)
          })
           // 字典
         await this.getDictData()
      },
      mounted() {
        const req = this.$route.query
        var sendType = req.sendType
        if (this.prjParams.workItemId) {
          console.log(formOption.itemData, 'formOption.itemData')
          formOption.itemData[0].disabled = true
          formOption.itemData[1].disabled = true
          formOption.itemData[2].disabled = true
          this.disabledType = true
        }

        if (sendType !== '2') {
          this.doSearch()
        } else {
          const dmdArr = [{
            prjId: req.prjId,
            prjCode: req.prjId,
            prjName: req.prjName,
            orgId: req.orgId,
            sendType: 2
          }]
          this.tableData = dmdArr
        }
      },
      methods: {
        // 2024-10-09 阻断问题if过多解决方案
        async optimizeNewOne(item) {
                this.btnOption = [] // 不展示删除 添加
                this.btnOptionBotm = [] // 不展示确认和关闭按钮
                this.$refs.topBtnText.style.display = 'none'
                const pramsOne = {
                    pageNum: item?.page || SysConst.CURRENT_PAGE,
                    pageSize: item?.limit || SysConst.PAGESIZE,
                    dispatchId: ''
                  }
                await getTDispatchInfoById({ workItemId: this.prjParams.workItemId }).then(res => {
                      if (+res.code !== 200) {
                  return Promise.reject(res)
        }
                      this.queryParams.dispatchType = res.data.dispatchType // 派单类型
                      this.queryParams.deadline = res.data.deadline // 解决期限
                      this.queryParams.taskTitle = res.data.taskTitle // 任务标题
                      this.queryParams.taskDescription = res.data.taskDescription // 任务描述
                      pramsOne.dispatchId = res.data.dispatchId
                  })
                await getTDispatchProjectById(pramsOne).then(res => {
                      if (+res.code !== 200) {
                  return Promise.reject(res)
        }
                      this.optimizeNewTwo(res)
                  })
        },
        // 2024-10-09 阻断问题if过多解决方案
        async optimizeNewTwo(res) {
                      this.tableData = res.data.list
                      // 分页
                      this.pageParam.total = res.data?.total || 0
                      this.pageParam.pageSize = res.data?.pageSize || SysConst.PAGESIZE
                      this.pageParam.pageNum = res.data?.pageNum || SysConst.CURRENT_PAGE
        },
        // 2024-10-09 阻断问题if过多解决方案
        async optimizeNewThree(res) {
                  this.tableData = res.data.list
                  this.pageParam.total = res.data?.total || 0
                  this.pageParam.pageSize = res.data?.pageSize || SysConst.PAGESIZE
                  this.pageParam.pageNum = res.data?.pageNum || SysConst.CURRENT_PAGE
        },
          // 查看数据
          async doSearch(item) {
              if (this.prjParams.workItemId) { // 待办走这里
                this.optimizeNewOne(item)
              } else {
                const pramsTwo = {
                  pageNum: item?.page || SysConst.CURRENT_PAGE,
                  pageSize: item?.limit || SysConst.PAGESIZE,
                  prjIds: this.prjParams.prjId
                }
                // const reqObj = this.$router.query
                // console.log(reqObj, "reqObj");
                getProjectInfo(pramsTwo).then(res => {
                  if (+res.code !== 200) {
                  return Promise.reject(res)
        }
                    this.optimizeNewThree(res)
              })
              }
          },
          // 获取下拉框数据
          async getDictData() {
              const arr = ['TDISPATCH_TYPE']
              const promises = arr.map(item => getDropdownData(item))
              const results = await Promise.all(promises)
              arr.forEach((item, i) => {
                  this.$set(this.dicLists, item, results[i].data ?? [])
              })
          },
          // 接单人选择
          sendStaffFun(val) {
            this.sendOrdersDialog = true
            // 存放重新派单信息
            this.sendStaValObj = val
            this.transferRecordAdd()
          },
          // 列表按钮点击事件
          btnClick(fun, row) {
              this[fun](row)
          },
          // 项目名称-基本信息
          async prjNameFun(val) {
            // crm业务
            if (val.sendType === '2' || val.sendType === 2) {
              const foreignObj = await getForeignConfig({ itfCodeStatus: '1' })
              if (foreignObj.code === '200') {
                var foreignData = foreignObj.data
                const getUserObj = await getUserInfo({ })
                this.redirceCRM(val, foreignData, getUserObj.data)
              }
            } else {
              this.dialogVisible = true
               // 基本信息
              await getProjectInfoByPrjId({ prjId: val.prjId }).then(res => {
              if (+res.code !== 200) {
                  return Promise.reject(res)
        }
                  this.queryParamsBasic = res.data
                })
            }
          },

          // 跳转到CRM详情页面
          async redirceCRM(val, foreignData, userInfo) {
            const applyTokenByCodeData = await applyTokenByCode({ serviceId: 'CHNTCRM', loginAcct: userInfo.user.loginName })
            if (applyTokenByCodeData.code === '200') {
              var applyTokenByCodeList = applyTokenByCodeData.data
              // 2022-04-28 跳转页面使用post方式
              var pwdaToken = applyTokenByCodeList.TOKEN
              var acctId = applyTokenByCodeList.ACCTID
              var toUrl = foreignData.servUrl + encodeURIComponent('/crm/pages/lease/index.html#/biz?requestId=' + val.prjId + '&pgCode=CRM_REQ_REV_VIEW')
              var params = {}
              params.pwdaToken = pwdaToken
              params.acctId = acctId
              params.UserCode = userInfo.user.loginName
              params.callPara = ''
              console.log(toUrl, params, 'toUrlparams')
              newOpenPostWindow(toUrl, params)
            }
          },
          // 是否转派
          transferOrNotFun(row) {
            this.dialogsTitle = '转派记录查看'
            this.dialogs = true
            getTransferRecord({ id: row.id }).then(res => {
                  if (+res.code !== 200) {
                  return Promise.reject(res)
        }
                  this.explainTableData = res.data
              })
            console.log('是否转派')
          },
          shwoFileName(row) {
            if (row.fileList !== undefined && row.fileList.length > 0) {
              return row.fileList[0].fileName
            }
          },
          downLoadFile(row) {
            if (row.fileList.length > 0) {
              window.open(row.fileList[0].fileUrl)
            }
          },
          // 添加
          pushFun() {
            this.tableDataOld = this.tableData
            console.log(this.$refs.BusinessOrderPush, 'this.$refs.BusinessOrderPush')
            // this.$refs.BusinessOrderPush.sendOrdersDialogVisible = true
            this.$refs.BusinessOrderPush.ifmCre()
          },
          // 添加确认
          updateValue(vale, item) {
            const pramsTwo = {
                  pageNum: item?.page || SysConst.CURRENT_PAGE,
                  pageSize: item?.limit || SysConst.PAGESIZE,
                  prjIds: vale.join(',')
                }
                getProjectInfo(pramsTwo).then(res => {
                  if (+res.code !== 200) {
                  return Promise.reject(res)
        }
                  this.pageParam.total = res.data?.total || 0
                  this.pageParam.pageSize = res.data?.pageSize || SysConst.PAGESIZE
                  this.pageParam.pageNum = res.data?.pageNum || SysConst.CURRENT_PAGE
                  res.data.list.map(v => {
                    this.tableData.push(v)
                  })
                  this.$message.success('添加成功!')
                })
          },
          // 接单人员选择
          pushAdd() {
            console.log(this.userSelected.empName, 'this.userSelected111')
            if (!this.userSelected.empName) {
              this.$message.info('请选择接单人')
              return
            }
            const databj = this.sendStaValObj//  当前点击的数据
            console.log(databj, 'databj')
            if (databj.processingProgress === '3' || databj.processingProgress === '4') {
                const pushAddPrams = {
                          tDispatchInfo: {
                            dispatchType: this.queryParams.dispatchType,
                            taskTitle: this.queryParams.taskTitle
                          },
                          sendCode: databj.sendCode,
                          sendStaff: this.userSelected.empId,
                          id: databj.id
                       }
                creatDispatchProjectFlow(pushAddPrams).then(res => {
                    if (+res.code !== 200) {
                  return Promise.reject(res)
        }
                    this.doSearch()
                    this.sendOrdersDialog = false
                    this.$message.success('接单人员选择成功!')
                  })
            } else {
              this.tableData.map((val, i) => {
                if (val.prjId === databj.prjId) {
                  this.$set(this.tableData, i, {
                      ...this.tableData[i],
                      sendStaffName: this.userSelectedName,
                      sendStaff: this.userSelected.empId
                  })
                }
              })
              console.log('this.tableDat666a', this.tableData)
              this.sendOrdersDialog = false
              this.$message.success('接单人员选择成功')
              this.formVal = {}
              this.userSelected = {}
              this.toSelectdata = []
              this.toSelectdataTwo = []
            }
          },
          // 添加取消
          cancel() {
            this.formVal = {}
            this.userSelected = {}
            this.toSelectdata = []
              this.toSelectdataTwo = []
            this.handleColse()
          },
          // 删除
          delFun(row) {
            console.log(row, 'row')
            if (row.length < 1) {
              this.$message.info('请至少选择一条数据后,再进行删除操作')
              return
            }
            var oldTableData = this.tableData
                row.map(val => {
                  oldTableData = oldTableData.filter(item => item.prjId !== val.prjId)
                })
            this.tableData = oldTableData
          },
          // 确认
          formAdd(row) {
            let flag = true
            this.$refs.formRef.$refs.queryFormRef.validate((valid) => {
              flag = valid
            })
            if (!flag) {
              return
            }
            const tDispatchProjectVOListArr = []
            this.tableData.filter(item => tDispatchProjectVOListArr.push({ prjId: item.prjId, sendStaff: item.sendStaff, prjName: item.prjName, orgId: item.orgId, sendType: (item.sendType === null || item.sendType === undefined ? '1' : (item.sendType + '')) }))
            const params = {
              taskTitle: this.queryParams.taskTitle, // 任务标题
              dispatchType: this.queryParams.dispatchType, // 派单类型
              deadline: this.queryParams.deadline, // 解决期限
              taskDescription: this.queryParams.taskDescription, // 任务描述
              tDispatchProjectVOList: tDispatchProjectVOListArr
            }
            // map
            params.tDispatchProjectVOList.forEach(v => {
              if (!v.sendStaff) {
                flag = false
              }
            })
            if (!flag) {
              this.$message.info('有未选择接单人,请选择接单人!')
              return
            }
            console.log(params, 'dispatchInfoParam')
            insertTDispatchInfo(params).then(res => {
                if (+res.code !== 200) {
                  return Promise.reject(res)
        }
                this.$message.success(res.message)
                this.dialogCheckboxFun()
            })
          },
          // 查看回执
          lookOpinion(vale) {
            console.log('vale', vale)
            this.opinionDialogs = true
            if (vale.processingProgress === '2') {
              this.opinionVal = vale.jobDescription
            } else {
              this.opinionVal = vale.opinion
            }
          },
          // 接单人查询
          transferRecordAdd() {
            const pramse = { name: this.formVal.name, loginName: this.formVal.loginName }
            // (内部人员)
            getSendStaffTree(pramse).then(res => {
                if (+res.code !== 200) {
                  return Promise.reject(res)
        }
                this.toSelectdata = res.data
            })
            // (服务商)
            getServicerSendStaffTree(pramse).then(res => {
                if (+res.code !== 200) {
                  return Promise.reject(res)
        }
                this.toSelectdataTwo = res.data
            })
            console.log(this.toSelectdata, this.toSelectdataTwo, 'this.toSelectdata')
          },
          // 关闭
          dialogCheckboxFun() {
            clonePage()
          },
          // 取消集合
          handleColse() {
              this.sendOrdersDialog = false
              this.dialogVisible = false
              this.dialogs = false
              this.opinionDialogs = false
          },
          // 设置高度
          setHeight(isFold) {
              const child = this.$refs.formRef.$refs
              const height = (formOption.itemData.length / 3).toFixed() - 0
              console.log(child, '🚗')
              // const height = (child.queryFormRef.$children.length / 3).toFixed() - 0
              this.$refs.queryFormBox.style.height = isFold ? `${height * 24}px` : '158px'
              // child.PmsFormRef.style.height = isFold ? `${height * 24}px` : '78px'
          },
          // 可选办理人
          currentChange(data, node) {
            console.log('[]')
          },
          // 已选接单人(内部人员)
          userClick(data, node) {
            if (+data.isLeaf === 1 && node.expanded) {
              const { id: empId, text: empName } = data
              this.userSelected = { empId, empName }
              this.selectedUserId = data.loginName
            }
          }
      }
  }
</script>

<style lang="scss" scoped>
    .search-flex-box {
        display: flex;
        justify-content: space-between;
        height: auto;
    }
    .searchBtn {
        width: 100px;
        margin-left: auto;
        display: flex;
        margin-top: 0px;
        flex-direction: column;
        .el-button + .el-button {
            margin-left: 0;
            margin-top: 8px;
        }
    }

    .electronicSignature {
        width: 100%;
        .mainDetails {
            padding: 20px 25px 0px;
        }
        .topRemark {
            // background-color: #fdf5e6;
            background-color: #ffefd5;
            width: 100%;
            height: 40px;
            line-height: 40px;
            padding-left: 10px;
            font-size: 14px;

            .asterisk {
                color: #f00;
                margin-right: 2px;
                font-size: 18px;
            }
        }

        .customBtn {
            height: 20px;
            line-height: 20px;
            font-size: 14px;
            margin: 10px 20px 10px 90%;
            cursor: pointer;

            .el-icon-s-tools {
                font-size: 20px;
                color: #999;
                margin-right: 6px;
            }
        }
    }

    .el-button--text {
        color: #02A7F0;
    }

    .el-button--primary {
        color: #fff;
    }
    .dialog-footer {
        display: flex;
        justify-content: center;
    }
    // ::v-deep .el-button + .el-button {
    //     color: #fff;
    // }
    // 弹框样式
    ::v-deep .el-dialog__body {
        max-height: 600px;
        overflow-y: auto;
    }
    // 滚动条样式
    ::v-deep .el-dialog__body::-webkit-scrollbar {
    // 滚动条整体样式
    width: 6px; //高宽分别对应横竖滚动条的尺寸
    height: 10px;
    }
    ::v-deep .el-dialog__body::-webkit-scrollbar-thumb {
    // 滚动条里面小方块
    border-radius: 10px;
    // -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    background: #f2f3f5;
    }
    ::v-deep .el-range-editor.el-input__inner {
        padding: 0px 10px;
    }

    .topBtn {
        text-align: center;
        padding: 20px;
    }
    .topBtnBox {
      display: inline-block;
    }
    ::v-deep .el-tag {
        border: none;
        color: #02A7F0;
        background-color: #FFFFFF;
    }
     ::v-deep .el-dialog__title {
         font-size: 14px;
         //font-weight: bold;
     }
     .TcoNewCss {
        border: none;
     }
     ::v-deep .el-collapse-item__wrap {
        border-bottom: none;
     }

     ::v-deep .el-dialog__body {
        padding: 20px;
     }
    ::v-deep .el-form-item .el-form-item__content {
      height: 100%
    }

    ::v-deep .el-collapse-item:last-child {
        margin-bottom: 1px;
    }

    ::v-deep .el-textarea.is-disabled .el-textarea__inner {
          background-color: #f7f7f7;
      }

    .Colorred {
      color: red;
    }

    .userTree-container{
      height: 250px;
      overflow-y: auto;
    }

    .container {
      .select {
        display: flex;
        align-items: center;
        .box {
          width: 100%;
          &:nth-child(n+2){
            margin-left: 10px;
          }
        }
        .title {
          width: 100%;
          height: 36px;
          line-height: 36px;
          text-align: left;
          font-size: 17px;
          font-weight: 900;
          // color: rgb(227, 47, 47);
          color: #eb4b4b;
        }
        .content {
          height: 250px;
          border: 1px solid #ccc;
          overflow: hidden;
          .node-item {
            height: 30px;
            line-height: 30px;
          //   text-align: left;
            text-indent: 1em;
            font-size: 12px;
            width: 100%;
            background-color: #DBDBDB;
            &:hover {
              cursor: pointer;
            }
            &.clicked {
              background-color: #ffefe5;
              color: #eb4b4b;
            }
          }
          .user-item {
            height: 22px;
            line-height: 22px;
          }
          .user-select-item {
            height: 30px;
            line-height: 30px;
            text-align: center;
            font-size: 12px;
            width: 100%;
            background-color: #F4F6F8;
          }
        }
        .icon {
          margin-right: 6px;
          font-size: 14px;
        }
        ::v-deep .el-icon-caret-right:before {
          content: ''
        }
      }
      .message {
        //margin-top: 10px;
        text-align: left;
      }
      .nextTips{
        margin-top: 5px;
        text-align: left;
      }
    }
    .containerTwo {
      .select {
        .box {
          width: 100%;
          &:nth-child(n+2){
            margin-left: 10px;
          }
        }
        .title {
          width: 100%;
          height: 36px;
          line-height: 36px;
          text-align: left;
          font-size: 17px;
          font-weight: 900;
          // color: rgb(227, 47, 47);
          color: #eb4b4b;
        }
        .contentTwo {
          height: 80px;
          border: 1px solid #ccc;
          overflow: hidden;
          .node-item {
            height: 30px;
            line-height: 30px;
          //   text-align: left;
            text-indent: 1em;
            font-size: 12px;
            width: 100%;
            background-color: #DBDBDB;
            &:hover {
              cursor: pointer;
            }
            &.clicked {
              background-color: #ffefe5;
              color: #eb4b4b;
            }
          }
          .user-item {
            height: 22px;
            line-height: 22px;
          }
          .user-select-item {
            height: 30px;
            line-height: 30px;
            text-align: center;
            font-size: 12px;
            width: 100%;
            background-color: #F4F6F8;
          }
        }
        .icon {
          margin-right: 6px;
          font-size: 14px;
        }
        ::v-deep .el-icon-caret-right:before {
          content: ''
        }
      }
      .message {
        //margin-top: 10px;
        text-align: left;
      }
      .nextTips{
        margin-top: 5px;
        text-align: left;
      }
    }

    .tagNew {
      color: #333333;
    }

    .search-panel-header {
			height: 45px;
			background: #fff;
			border-bottom: none;
			color: #201f35;
			display: flex;
			flex-direction: row;
      margin-top: -8px;
			// padding: 13px 10px 15px;
		}
    .search-panel-icon {
			width: 6px;
			height: 15px;
			border-radius: 12px;
			background: #eb4b4b;
			margin-left: 6px;
			margin-right: 10px;
		}
		.search-panel-title {
			height: 100%;
			line-height: 15px;
			font-size: 14px;
      font-weight: 550;
		}
    [data-v-a4cbc322] .el-tag{
      padding: 0px;
    }
</style>
